<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BarCode
 *
 * @author Administrator
 */
class BarCode extends CI_Controller
{

    function __construct()
    {
        parent::__construct();
        //加载模型
        $this->load->service('/wms/barcode_service');
        $this->load->service('/wms/grid_service');
        $this->load->model('/wms/api/get_product_info_from_erp');
    }

    function get_sku_barcode()
    {
        $gp=gp();
        $sku=trim($gp['sku']);
                $whs_code=trim($gp['whs_code']);
           if(''==  $sku){
                  $msg=lang('wms_tips_20004');
                              echo '{"success":false,"msg":"' . $msg . '"}';exit;
           }
        //名称，条码，时间，仓库代码，库位
        $temple_div = "<div class=\"sku_print\"style=\"page-break-after:always;height:2.9cm;width:5cm;\"id=\"printmain\"><div style=\"width:95%%;height:1.2cm;font-size:9px;line-height:11px;text-align:left;margin:auto;word-wrap:break-word\">%s</div><div style=\"width:90%%;height:1.3cm;margin:auto;\">%s</div><div style=\"width:95%%;height:0.35cm;margin:auto\"><div style=\"float:left;font-size:9px;\">%s</div><div style=\"float:left;font-size:12px;padding-left:20px\">%s</div><div style=\"float:right;font-size:12px;\">%s</div></div></div>";
        $w='1';
        $h='30';

        
        $barcode=  $this->barcode_service->getBarcodeHTML($sku,"C128",$w,$h,'black','');
        $barcode=str_replace("\n", "", $barcode);
        $skuinfo=$this->get_product_info_from_erp->get_info($sku);
        if(empty ($skuinfo)){
                              echo '{"success":false,"msg":"' . $msg . '"}';exit;
        }
        $product_name=$skuinfo[$sku]['products_name_cn'];
        $data=date('Y-m-d');
        $grid_id=$this->grid_service->get_sku_grid($whs_code, $sku);
        $div=sprintf($temple_div,$product_name,$barcode,$data,$whs_code,$grid_id);
                echo '{"success":true,"msg":"'.addslashes($div) .'"}';
    }

}

?>
